// 在utils/videoState.ts中
class VideoStateManager {
  private static instance: VideoStateManager;
  private listeners: ((isVisible: boolean) => void)[] = [];

  static getInstance(): VideoStateManager {
    if (!VideoStateManager.instance) {
      VideoStateManager.instance = new VideoStateManager();
    }
    return VideoStateManager.instance;
  }

  setVideoPageVisible(isVisible: boolean) {
    this.listeners.forEach(listener => listener(isVisible));
  }

  addListener(listener: (isVisible: boolean) => void) {
    this.listeners.push(listener);
  }

  removeListener(listener: (isVisible: boolean) => void) {
    const index = this.listeners.indexOf(listener);
    if (index > -1) {
      this.listeners.splice(index, 1);
    }
  }
}

export const videoStateManager = VideoStateManager.getInstance();
